home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- #include <stdio.h>
-
- extern long layerset, currentcolor;
-
- #define TOL (pbsize/1.0)
- #define NAMELENGTH 30
- #define UIWIDTH 230
- #define INVISIBLE -1
- #define SMEAR -2
- #define BLINK -3
-
- enum constrainttype {
- NULLCONSTRAINT,
- VERTFREE, // no constraints -- 2 degrees of freedom
- VERTONLINE, // vertex lies on line -- 1 D.O.F
- VERTONCIRCLE, // vertex on circle -- 1 D.O.F
- VERTDISTFROMLINE, // vertex a given distance from a line -- 1 D.O.F
- VERTLINELINE, // on intersection of 2 lines
- VERTLINECIRC1, // on intersection of line, circle
- VERTLINECIRC2, // on intersection of line, circle
- VERTCIRCCIRC1, // on circle/circle intersection
- VERTCIRCCIRC2, // on circle/circle intersection
- VERTCIRCCENTER, // vertex is circle's center
- VERTVERTVERTMID, // vertex is midpoint
- VERTLINEVERTMIRROR, // vertex is mirror image through line
- VERTCIRCVERTINV, // invert a vertex through a circle
- LINEVERTVERT, // line through 2 vertices
- LINEVERTLINEPAR, // line through vertex; parallel to line
- LINEVERTLINEPERP, // line through vertex; prependicular to line
- LINEVERTCIRC1, // through vertex; tangent to circle
- LINEVERTCIRC2, // through vertex; tangent to circle
- LINELINEPERPCIRC, // perpendicular to line; tangent to circle
- LINELINEPARCIRC, // parallel to line; tangent to circle
- LINECIRCCIRCEXT1, // external tangent to 2 circles
- LINECIRCCIRCEXT2, // external tangent to 2 circles
- LINECIRCCIRCINT1, // external tangent to 2 circles
- LINECIRCCIRCINT2, // external tangent to 2 circles
- CIRCVERTCIRC, // circle through vertex; tangent to circle
- CIRCVERTLINE, // through vertex, tangent to line
- CIRCVERTVERT, // through vertex, passing through another
- CIRCVERTDIST, // center at vertex, radius = distance
- CIRCVERTVERTVERT, // circle through 3 vertices
- CIRCLINELINELINE1, // tangent to 3 lines
- CIRCLINELINELINE2, // tangent to 3 lines
- CIRCLINELINELINE3, // tangent to 3 lines
- CIRCLINELINELINE4, // tangent to 3 lines
- CIRCCIRCCIRCCIRC, // tangent to 3 circles
- CIRCVERTVERTLINE, // through 2 vertices; tangent to line
- CIRCVERTVERTCIRC, // through 2 vertices; tangent to circle
- CIRCLINELINEVERT, // tangent to 2 lines; through vertex
- CIRCLINELINECIRC, // tangent to 2 lines and a circle
- CIRCCIRCCIRCVERT, // tangent to 2 circles and through vertex
- CIRCCIRCCIRCLINE, // tangent to 2 circles and a line
- CIRCVERTLINECIRC, // through a vertex; tangent to a line and circle
- CIRCCIRCCIRCINV, // invert a circle through another
- CIRCLINECIRCINV, // invert a line through a circle
- BEZVERTVERTVERTVERT,
- BSPVERTVERTVERTVERT,
- RATIOVERTVERTVERT,
- VERTVERTVERTRATIO,
- LENVERTVERT,
- CIRCVERTLEN,
- LENPLUSLENLEN,
- LENMINUSLENLEN,
- ANGLEVERTVERTVERT,
- VERTANGLEVERTVERT,
- ANGLEANGLETRISECT, // angle = angle/3
- ANGLEANGLELEN, // angle = angle*float
- ANGLEFLOAT, // angle = float
- LENFLOAT, // len = float
- LENTIMESLENLEN,
- LENDIVLENLEN,
- CONICFIVEVERT, // conic from 5 vertices
- VERTONCONIC,
- LINETANGENTCONIC1,
- LINETANGENTCONIC2,
- CONICFIVELINE, // conic from 5 lines
- VERTLINECONIC1,
- VERTLINECONIC2,
- LENANGLE,
- };
-
- class constraint {
- public:
- constrainttype type;
- class primitive *p1, *p2, *p3, *p4, *p5;
- };
-
- class primitive {
- public:
- primitive *next;
- // char iname[NAMELENGTH];
- char name[NAMELENGTH];
- struct symtableentry *st;
- constraint c;
- long satisfied; // constraint c is satisfied
- long Color;
- long layers;
- reservedword ptype;
- primitive() { next = (primitive *)0; name[0] = (char)0;
- c.p1 = c.p2 = c.p3 = c.p4 = c.p5 = (primitive *)0;
- Color = (currentcolor== -1)?7:currentcolor;
- satisfied = 0; layers = layerset; }
- };
-
- class vertex : public primitive {
- public:
- float xw, yw, w;
- void draw();
- void PostScript(FILE *);
- long hitvertex(float, float);
- void projecttoline(class line *);
- reservedword type;
- vertex() { ptype = _vertex; xw = yw = 0.0; w = 1.0; type = _diamond; }
- };
-
- // the ratio class is a ratio of distances --
- // (_ratio v1 v2 v3) == length(v1v2)/length(v1v3)
- // usually v2 is between v1 and v3
-
- class length : public primitive {
- public:
- float value;
- void draw();
- void PostScript(FILE *);
- length() { ptype = _length; value = 0.5; }
- };
-
- //class ratio : public primitive {
- //public:
- // float value;
- // void draw();
- // void PostScript(FILE *);
- // ratio() { ptype = _ratio; value = 0.5; }
- //};
-
- //class angle : public primitive {
- //public:
- // float value;
- // void draw();
- // void PostScript(FILE *);
- // angle() { ptype = _angle; value = 1.570796326; }
- //};
-
- class comment : public primitive {
- public:
- char str[150];
- void draw();
- void PostScript(FILE *);
- comment() { ptype = _comment; str[0] = (char)0; }
- };
-
- class text : public primitive {
- public:
- char str[150];
- void draw();
- void PostScript(FILE *);
- text() { ptype = _text; str[0] = (char)0; }
- };
-
- class line : public primitive {
- public:
- vertex v1, v2;
- float XW, YW, W;
- reservedword type;
- void draw();
- void PostScript(FILE *);
- long hitline(float, float);
- float disttoline(float, float);
- line() { ptype = _line; type = _segment; v1.w = 0.0; }
- };
-
- class bezier : public primitive {
- public:
- vertex v1, v2, v3, v4;
- void draw();
- void PostScript(FILE *);
- long hitbezier(float, float);
- float disttobezier(float, float);
- bezier() { ptype = _bezier; v1.w = 0.0; }
- };
-
- class circle : public primitive {
- public:
- vertex center;
- float radius;
- vertex v1, v2, v3;
- void draw();
- void PostScript(FILE *);
- long hitcircle(float, float);
- float disttocircle(float, float);
- circle() { ptype = _circle; center.w = 0.0; }
- };
-
- class conic : public primitive {
- public:
- double aa, bb, cc, dd, ee, ff;
- void draw();
- void PostScript(FILE *);
- long hitconic(float, float);
- float disttoconic(float, float);
- conic() { ptype = _conic; }
- };
-